<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3" xmlns:head="http://www.w3.org/1999/html">
<head th:include="public/public_css::public_css ('欠货订单处理')" />

<link rel="stylesheet" type="text/css" th:href="@{/plugin/layui/css/font/iconfont.css}" media="all"/>
<link rel="stylesheet" type="text/css" th:href="@{/plugin/layui/js/layui/css/layui.css}" media="all"/>
<link rel="stylesheet" type="text/css" th:href="@{/css/main.css}" media="all"/>
<body style="background-color: #f2f2f2;">
<div class="layui-fluid larry-wrapper">
    <div class="layui-card">
        <div class="layui-row layui-col-space30">
            <div class="layui-col-xs24">
                <form class="layui-form layui-card-header  layui-card-header-auto" id="searchForm">
                    <div class="layui-inline">
                        <label class="layui-form-label">SO编号</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="fybh" name="fybh" />
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">客户订单号</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="khddh" name="khddh" />
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">交货方式</label>
                        <select name="jhfs" lay-filter="aihao">
                            <option value=""></option>
                            <option value="">全部</option>
                            <option value="0">发运</option>
                            <option value="1">自提</option>
                        </select>

                    </div>
                    <div class="layui-inline inline-search-btn">
                        <a class="layui-btn layui-btn-normal" data-type="reload" id="search_button">查询</a>
                    </div>
                    <div class="layui-inline inline-reset-btn">
                        <button type="reset" class="layui-btn layui-btn-primary" style="background-color: #1e9fff;color: white;"><font>重置</font></button>
                    </div>
                </form>
                <!--<div class="moreBtn"><i class="layui-icon layui-icon-triangle-d" style="color: #1E9FFF;"></i></div>-->
                <!--顶部按钮展示区域 【 tpl-button 】 -->
                <div class="group-button tpl-button" id="toolbar"></div>

                <!-- <div class="group-button" id="toolbar">-->

                <!-- <a class="layui-btn layui-btn-sm layui-btn-normal add-btn">
                      <i class="layui-icon">&#x1005;</i> 添加
                  </a>-->

            </div>
            <!--列表-->
            <section class="panel panel-padding layui-card-body" >
                <div class="pro">
                    <table id="table"  class="table text-nowrap" style="word-break:break-all; word-wrap:break-word;"></table>
                </div>
            </section>
        </div>
    </div>
</div>
</div>
</body>
<style>
    .tooltip2{
        display: inline-block;
        margin-left: 1rem;
    }
</style>
<div th:include="public/public_js::public_js"></div>
<div th:include="public/public_btn::public_btn"></div>

<script th:inline="javascript">
    // 多余查询条件隐藏
    $(function () {
        $(".moreBtn").on("click",function () {
            $(".moreSearch").toggle();
        })
    });
    //	回车查询
    document.onkeydown = function(event) {
        e = event ? event : (window.event ? window.event : null);
        if (e.keyCode == 13) {
            //执行的方法
            $('#search_button').click();
        }
    };
    function TEST() {
        console.log('测试！！！！！！！！！！！');
    }
    //
    var functions = [[${functions}]];
    layui.use(['list','layer','zzpUtils','jquery','laydate', 'tablebutton'],function () {
        var zzpUtils= layui.zzpUtils,
            $ = layui.jquery,
            layer=layui.layer,
            laydate = layui.laydate,
            tablebtn = layui.tablebutton;
        tablebtn.buildOnClick({
            type: 1,
            temp: $("#function_tpl"),
            functions: functions.headBtn,
            row: null,
            event: {
                // 查看outOperation_shipment_searchEvent
                searchEvent: function(data){
                    console.log("点查询了", data.row);
                    lookDialog(data.row);
                },
                // 追加分配
                allocationEvent: function (data) {
                    if (data.row != undefined) {
                        var ids = [];
                        ids.push(data.row.id)
                        allocation(ids);
                    } else {
                        var arr = [];
                        var $rows = $table.bootstrapTable('getSelections');
                        if ($rows.length > 0) {
                            arr = $.map($rows, function (row) {
                                return row.id;
                            })
                            allocation(arr);
                        }else{
                            layer.msg("至少选择一条数据");
                        }
                    }
                },
                // 查看拆单明细
                searchSeparatedDetailEvent: function (data) {
                    if (data.row) {
                        searchSeparatedDetailDialog(data.row);
                    }
                },
                // 查看分配明细
                searchAllocationDetailEvent: function (data) {
                    if (data.row) {
                        searchAllocationDetailDialog(data.row);
                    }
                },
                // 查看装箱明细
                searchPackingDetailEvent: function (data) {
                    if (data.row) {
                        searchPackingDetailDialog(data.row);
                    }
                },
            }
        });
        // 追加分配
        function allocation(data) {
            var Ids = {ids: data};
            zzpUtils.confirm("您将对选择的发运订单进行追加分配",function(index){
                $.ajax({
                    url: '/zxsdwms/wmsdistribution/addDistribution',
                    type: 'POST',
                    dataType: 'json',
                    contentType: 'application/json',
                    data: JSON.stringify(Ids),
                    success: function (data) {
                        if(data.type === 'success') {
                            layer.msg(data.title);
                            $('#table').bootstrapTable('refresh');
                        } else {
                            layer.msg(data.message);
                        }
                    }
                })
            })
        }
        // 查看拆单明细
        function searchSeparatedDetailDialog(row) {
            localStorage.id = row.id;
            zzpUtils.dialog({
                title:"查看拆单明细",
                type:2,
                content: "/orderhandling/SeparatedDetail",
                area: ['80%', '70%']
            })
        }
        // 查看分配明细
        function searchAllocationDetailDialog(row) {
            localStorage.id = row.id;
            zzpUtils.dialog({
                title:"查看分配明细",
                type:2,
                    content: "/orderhandling/AllocationDetail",
                area: ['80%', '70%']
            })
        }
        // 查看装箱明细
        function searchPackingDetailDialog(row) {
            localStorage.id = row.id;
            zzpUtils.dialog({
                title:"查看装箱明细",
                type:2,
                content: "/orderhandling/PackingDetail",
                area: ['80%', '70%']
            })
        }



        function printBoxLabelEvent(row) {

        }
        // 模糊查询 客户创建时间
        laydate.render({
            elem: '#khcjsj'
            , theme: '#20a0ff',
            range:true
        });
        // 主页面table
        var $table = zzpUtils.table({
            elem: '#table',
            isApi: true,
            pagination:true,
            isOperate: true,
            functions: functions.tableBtn,
            url: '/wmsshipmentorder/list',
            columns: [
                {
                    field: '',
                    checkbox: true
                },
                {
                    field: 'khcjsj',
                    title: '客户创建时间',
                    formatter: function (value, row, index) {
                        var sj='';
                        if(value!=null&&value!=''){
                            sj=value.substring(0,19);
                        }
                        return sj;
                    }
                }, {
                    field: 'cjsj',
                    title: 'WMS创建时间',
                    formatter: function (value, row, index) {
                        var sj='';
                        if(value!=null&&value!=''){
                            sj=value.substring(0,19);
                        }
                        return sj;
                    }
                }, {
                    field: 'fybh',
                    title: 'SO编号'
                }, {
                    field: 'khddh',
                    title: '客户订单号'
                }, {
                    field:'show_fylx',
                    title:'SO类型'
                }, {
                    field:'show_jhfs',
                    title:'交货方式'
                },
            ],
           queryParams: function () {//查询条件
               return  zzpUtils.getFormJson($("#searchForm"));
           },
            operateFormatter: operateFormatter

        });
        //点击搜索 调用的查询方法
        $(".inline-search-btn").on('click', function () {
            zzpUtils.refreshTable("#table");
        })

        /*表格右侧按钮*/
        function operateFormatter(value, row, index) {
            var button="";
            for (var i = 0; i < functions.tableBtn.length; i++) {
                var item = functions.tableBtn[i];
                var btn = '<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="' + functions.tableBtn[i].event + '">'
                    + functions.tableBtn[i].name
                    + '</a>';
                if (row.fyzt) {
                    button += btn;
                }else{
                    if (functions.tableBtn[i].name == '查看') {
                        button += btn;
                    }else{
                        button+='<button class="layui-btn layui-btn-xs layui-btn-disabled" disabled lay-event="' + item.event + '">'
                            + item.name
                            + '</button>';
                    }

                }
            }
            return button;
        }
    });
</script>

</html>